|
1
|
|
|
var whois = require('../../common/whoiswrapper.js'), |
|
2
|
|
|
conversions = require('../../common/conversions.js'); |
|
3
|
|
|
|
|
4
|
|
|
require('../../common/stringformat.js'); |
|
5
|
|
|
|
|
6
|
|
|
const { |
|
7
|
|
|
ipcRenderer |
|
8
|
|
|
} = require('electron'); |
|
9
|
|
|
|
|
10
|
|
|
const base = 10; |
|
11
|
|
|
|
|
12
|
|
|
/* |
|
13
|
|
|
// Receive whois lookup reply |
|
14
|
|
|
ipcRenderer.on('bulkwhois:results', function(event, domain, domainResults) { |
|
15
|
|
|
|
|
16
|
|
|
//ipcRenderer.send('app:debug', "Whois domain reply for {0}:\n {1}".format(domain, domainResults)); |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
(function() { |
|
20
|
|
|
var result; |
|
21
|
|
|
if (typeof domainResults === 'object') { |
|
22
|
|
|
JSON.stringify(domainResults, null, 2); |
|
23
|
|
|
result = domainResults.map(function(data) { |
|
24
|
|
|
data.data = parseRawData(data.data); |
|
25
|
|
|
return data; |
|
26
|
|
|
}); |
|
27
|
|
|
} else { |
|
28
|
|
|
result = parseRawData(domainResults); |
|
29
|
|
|
} |
|
30
|
|
|
return result; |
|
31
|
|
|
})(); |
|
32
|
|
|
|
|
33
|
|
|
}); |
|
34
|
|
|
*/ |
|
35
|
|
|
|
|
36
|
|
|
/* |
|
37
|
|
|
// Receive bulk whois results |
|
38
|
|
|
ipcRenderer.on('bulkwhois:resultreceive', function(event, results) { |
|
39
|
|
|
|
|
40
|
|
|
}); |
|
41
|
|
|
*/ |
|
42
|
|
|
|
|
43
|
|
|
// Bulk whois processing, ui status update |
|
44
|
|
|
ipcRenderer.on('bw:status.update', function(event, stat, value) { |
|
45
|
|
|
ipcRenderer.send('app:debug', "{0}, value update to {1}".format(stat, value)); // status update |
|
46
|
|
|
var percent; |
|
47
|
|
|
switch (stat) { |
|
48
|
|
|
case 'start': |
|
49
|
|
|
if ($('#bwProcessingButtonNext').hasClass('is-hidden') === false) { |
|
50
|
|
|
$('#bwProcessingButtonNext').addClass('is-hidden'); |
|
51
|
|
|
$('#bwProcessingButtonPause').removeClass('is-hidden'); |
|
52
|
|
|
$('#bwProcessingButtonStop').removeClass('is-hidden'); |
|
53
|
|
|
} |
|
54
|
|
|
break; |
|
55
|
|
|
case 'domains.processed': // processed domains |
|
56
|
|
|
percent = parseFloat((value / parseInt($('#bwProcessingSpanTotal').text(), base) * 100).toFixed(1)) || 0; |
|
57
|
|
|
$('#bwProcessingSpanProcessed').text('{0} ({1}%)'.format(value, percent)); |
|
58
|
|
|
break; |
|
59
|
|
|
case 'domains.waiting': // whois requests waiting reply |
|
60
|
|
|
percent = parseFloat((value / parseInt($('#bwProcessingSpanSent').text(), base) * 100).toFixed(1)) || 0; |
|
61
|
|
|
$('#bwProcessingSpanWaiting').text('{0} ({1}%)'.format(value, percent)); |
|
62
|
|
|
break; |
|
63
|
|
|
case 'domains.sent': // sent whois requests |
|
64
|
|
|
percent = parseFloat((value / parseInt($('#bwProcessingSpanTotal').text(), base) * 100).toFixed(1)) || 0; |
|
65
|
|
|
$('#bwProcessingSpanSent').text('{0} ({1}%)'.format(value, percent)); |
|
66
|
|
|
break; |
|
67
|
|
|
case 'domains.total': // total domains |
|
68
|
|
|
$('#bwProcessingSpanTotal').text(value); |
|
69
|
|
|
break; |
|
70
|
|
|
case 'time.current': // current time |
|
71
|
|
|
$('#bwProcessingSpanTimecurrent').text('{0}'.format(value)); |
|
72
|
|
|
break; |
|
73
|
|
|
case 'time.remaining': // remaining time |
|
74
|
|
|
$('#bwProcessingSpanTimeremaining').text('{0}'.format(value)); |
|
75
|
|
|
break; |
|
76
|
|
|
case 'reqtimes.maximum': // maximum request reply time |
|
77
|
|
|
$('#bwProcessingSpanReqtimemax').text('{0}ms'.format(value)); |
|
78
|
|
|
break; |
|
79
|
|
|
case 'reqtimes.minimum': // minimum request reply time |
|
80
|
|
|
$('#bwProcessingSpanReqtimemin').text('{0}ms'.format(value)); |
|
81
|
|
|
break; |
|
82
|
|
|
case 'reqtimes.last': // last request reply time |
|
83
|
|
|
$('#bwProcessingSpanReqtimelast').text('{0}ms'.format(value)); |
|
84
|
|
|
break; |
|
85
|
|
|
case 'reqtimes.average': // Average request reply time |
|
86
|
|
|
$('#bwProcessingSpanReqtimeavg').text('{0}ms'.format(value)); |
|
87
|
|
|
break; |
|
88
|
|
|
case 'status.available': // Domains available |
|
89
|
|
|
percent = parseFloat((value / parseInt($('#bwProcessingSpanTotal').text(), base) * 100).toFixed(1)) || 0; |
|
90
|
|
|
$('#bwProcessingSpanStatusavailable').text('{0} ({1}%)'.format(value, percent)); |
|
91
|
|
|
break; |
|
92
|
|
|
case 'status.unavailable': // Domains unavailable |
|
93
|
|
|
percent = parseFloat((value / parseInt($('#bwProcessingSpanTotal').text(), base) * 100).toFixed(1)) || 0; |
|
94
|
|
|
$('#bwProcessingSpanStatusunavailable').text('{0} ({1}%)'.format(value, percent)); |
|
95
|
|
|
break; |
|
96
|
|
|
case 'status.error': // Domains error |
|
97
|
|
|
percent = parseFloat((value / parseInt($('#bwProcessingSpanTotal').text(), base) * 100).toFixed(1)) || 0; |
|
98
|
|
|
$('#bwProcessingSpanStatuserror').text('{0} ({1}%)'.format(value, percent)); |
|
99
|
|
|
break; |
|
100
|
|
|
case 'laststatus.available': // Last available domain |
|
101
|
|
|
$('#bwProcessingSpanLaststatusavailable').text('{0}'.format(value)); |
|
102
|
|
|
break; |
|
103
|
|
|
case 'laststatus.unavailable': // Last unavailable domain |
|
104
|
|
|
$('#bwProcessingSpanLaststatusunavailable').text('{0}'.format(value)); |
|
105
|
|
|
break; |
|
106
|
|
|
case 'laststatus.error': // Last error domain |
|
107
|
|
|
$('#bwProcessingSpanLaststatuserror').text('{0}'.format(value)); |
|
108
|
|
|
break; |
|
109
|
|
|
case 'finished': // Finished |
|
110
|
|
|
$('#bwProcessingButtonPause').addClass('is-hidden'); |
|
111
|
|
|
$('#bwProcessingButtonStop').addClass('is-hidden'); |
|
112
|
|
|
$('#bwProcessingButtonNext').removeClass('is-hidden'); |
|
113
|
|
|
break; |
|
114
|
|
|
default: |
|
115
|
|
|
break; |
|
116
|
|
|
} |
|
117
|
|
|
}); |
|
118
|
|
|
|
|
119
|
|
|
// Bulk processing, pause/continue process |
|
120
|
|
|
$('#bwProcessingButtonPause').click(function() { |
|
121
|
|
|
var searchStatus = $('#bwProcessingButtonPauseSpanText').text(); |
|
122
|
|
|
switch (searchStatus) { |
|
123
|
|
|
case 'Continue': |
|
124
|
|
|
setPauseButton(); |
|
125
|
|
|
ipcRenderer.send('bw:lookup.continue'); |
|
126
|
|
|
break; |
|
127
|
|
|
case 'Pause': |
|
128
|
|
|
$('#bwProcessingButtonPause').removeClass('is-warning').addClass('is-success'); |
|
129
|
|
|
$('#bwProcessingButtonPauseicon').removeClass('fa-pause').addClass('fa-play'); |
|
130
|
|
|
$('#bwProcessingButtonPauseSpanText').text('Continue'); |
|
131
|
|
|
ipcRenderer.send('bw:lookup.pause'); |
|
132
|
|
|
break; |
|
133
|
|
|
default: |
|
134
|
|
|
break; |
|
135
|
|
|
} |
|
136
|
|
|
}); |
|
137
|
|
|
|
|
138
|
|
|
function setPauseButton() { |
|
139
|
|
|
$('#bwProcessingButtonPause').removeClass('is-success').addClass('is-warning'); |
|
140
|
|
|
$('#bwProcessingButtonPauseicon').removeClass('fa-play').addClass('fa-pause'); |
|
141
|
|
|
$('#bwProcessingButtonPauseSpanText').text('Pause'); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
// Trigger Bulk whois Stop modal |
|
145
|
|
|
$('#bwProcessingButtonStop').click(function() { |
|
146
|
|
|
ipcRenderer.send('app:debug', "Pausing whois & opening stop modal"); |
|
147
|
|
|
$('#bwProcessingButtonPause').text().includes('Pause') ? $('#bwProcessingButtonPause').click() : false; |
|
148
|
|
|
$('#bwProcessingModalStop').addClass('is-active'); |
|
149
|
|
|
}); |
|
150
|
|
|
|
|
151
|
|
|
// Close modal and allow continue |
|
152
|
|
|
$('#bwProcessingModalStopButtonContinue').click(function() { |
|
153
|
|
|
ipcRenderer.send('app:debug', "Closing Stop modal & continue"); |
|
154
|
|
|
$('#bwProcessingModalStop').removeClass('is-active'); |
|
155
|
|
|
}); |
|
156
|
|
|
|
|
157
|
|
|
// Stop bulk whois entirely and scrape everything |
|
158
|
|
|
$('#bwProcessingModalStopButtonStop').click(function() { |
|
159
|
|
|
ipcRenderer.send('app:debug', "Closing Stop modal & going back to start"); |
|
160
|
|
|
$('#bwpStopModal').removeClass('is-active'); |
|
161
|
|
|
$('#bwProcessing').addClass('is-hidden'); |
|
162
|
|
|
setPauseButton(); |
|
163
|
|
|
$('#bwEntry').removeClass('is-hidden'); |
|
164
|
|
|
}); |
|
165
|
|
|
|
|
166
|
|
|
// Stop bulk whois entirely and save/export |
|
167
|
|
|
$('#bwProcessingModalStopButtonStopsave').click(function() { |
|
168
|
|
|
ipcRenderer.send('app:debug', "Closing Stop modal & exporting"); |
|
169
|
|
|
ipcRenderer.send('bw:lookup.stop'); |
|
170
|
|
|
$('#bwProcessingModalStop').removeClass('is-active'); |
|
171
|
|
|
$('#bwProcessing').addClass('is-hidden'); |
|
172
|
|
|
setPauseButton(); |
|
173
|
|
|
$('#bwExport').removeClass('is-hidden'); |
|
174
|
|
|
}); |
|
175
|
|
|
|
|
176
|
|
|
// Bulk processing, proceed to export options |
|
177
|
|
|
$('#bwProcessingButtonNext').click(function() { |
|
178
|
|
|
$('#bwProcessing').addClass('is-hidden'); |
|
179
|
|
|
$('#bwExport').removeClass('is-hidden'); |
|
180
|
|
|
}); |
|
181
|
|
|
|